Skip to content

feat(vmcp): log active sessions on creation, expiry, and periodically#4019

Draft
yrobla wants to merge 2 commits intomainfrom
issue-3876
Draft

feat(vmcp): log active sessions on creation, expiry, and periodically#4019
yrobla wants to merge 2 commits intomainfrom
issue-3876

Conversation

@yrobla
Copy link
Copy Markdown
Contributor

@yrobla yrobla commented Mar 5, 2026

Log session lifecycle events and periodic active session counts for operational debugging and compliance auditing when sessionManagementV2 is enabled.

Changes

  • Manager.CreateSession(): upgraded log to Info with session ID, backend count, and backend names
  • Manager.Terminate(): log Info with session ID and backend count when a MultiSession expires; separate log for placeholder termination
  • Manager.StartPeriodicLogging(ctx, interval): new method that starts a background goroutine logging active session counts every minute
  • Manager.logActiveSessions(): internal helper that iterates sessions via Range(), aggregates per-backend session counts, and logs a summary; logs a one-time warning when distributed storage makes enumeration unavailable
  • Server.Start(): calls StartPeriodicLogging when SessionManagementV2 is enabled

Removed

  • /status endpoint session fields (Sessions, SessionsStatus, BackendUsage) — session data is now surfaced through logs only
  • ListActiveSessions() from SessionManager interface

Closes: #3876

@yrobla yrobla requested a review from Copilot March 5, 2026 15:28
@github-actions github-actions bot added the size/M Medium PR: 300-599 lines changed label Mar 5, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00fd4857c7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkg/vmcp/server/status.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds session visibility to the vMCP /status endpoint to support operational debugging and compliance auditing when SessionManagementV2 is enabled.

Changes:

  • Extend /status response schema to optionally include active vMCP sessions and backend session ID mappings.
  • Add ListActiveSessions() to the session manager and expose the data through buildStatusResponse.
  • Add unit tests for ListActiveSessions() behavior and a regression test that sessions is omitted when V2 is disabled.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pkg/vmcp/server/status.go Adds optional sessions block to /status when SessionManagementV2 is enabled.
pkg/vmcp/server/status_test.go Updates status response test DTOs; adds tests for sessions omission and backend field redaction.
pkg/vmcp/server/sessionmanager/session_manager.go Introduces SessionInfo and implements ListActiveSessions().
pkg/vmcp/server/sessionmanager/list_sessions_test.go Adds tests for listing behavior across empty, placeholder-only, and populated stores.
pkg/vmcp/server/session_manager_interface.go Extends the SessionManager interface with ListActiveSessions().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/vmcp/server/status_test.go Outdated
Comment thread pkg/vmcp/server/status.go Outdated
Comment thread pkg/vmcp/server/sessionmanager/session_manager.go Outdated
Comment thread pkg/vmcp/server/sessionmanager/session_manager.go Outdated
Comment thread pkg/vmcp/server/session_manager_interface.go Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 5, 2026

Codecov Report

❌ Patch coverage is 28.12500% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.63%. Comparing base (0791876) to head (3ad3eae).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/vmcp/server/sessionmanager/session_manager.go 33.96% 35 Missing ⚠️
pkg/vmcp/server/server.go 0.00% 7 Missing and 1 partial ⚠️
pkg/transport/session/manager.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4019   +/-   ##
=======================================
  Coverage   68.62%   68.63%           
=======================================
  Files         445      445           
  Lines       45374    45426   +52     
=======================================
+ Hits        31140    31178   +38     
- Misses      11827    11843   +16     
+ Partials     2407     2405    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Mar 5, 2026
@github-actions github-actions bot added size/L Large PR: 600-999 lines changed and removed size/M Medium PR: 300-599 lines changed labels Mar 6, 2026
Copy link
Copy Markdown
Contributor

@jerm-dro jerm-dro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change really necessary? I get that it'd be nice to have visibility into active sessions, but exposing an endpoint seems heavy-handed. Alternative approaches:

  • periodically log all the active sessions in memory
  • log sessions as they are created and expired

What do you think?

@yrobla yrobla changed the title feat(vmcp): expose active backend sessions on /status endpoint feat(vmcp): log active sessions on creation, expiry, and periodically Mar 9, 2026
@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/L Large PR: 600-999 lines changed size/S Small PR: 100-299 lines changed labels Mar 9, 2026
Add session visibility to the /status endpoint for operational debugging
and compliance auditing when sessionManagementV2 is enabled.

Closes: #3876
@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Mar 9, 2026
@yrobla
Copy link
Copy Markdown
Contributor Author

yrobla commented Mar 9, 2026

Is this change really necessary? I get that it'd be nice to have visibility into active sessions, but exposing an endpoint seems heavy-handed. Alternative approaches:

  • periodically log all the active sessions in memory
  • log sessions as they are created and expired

What do you think?

ok this task came generated by claude, based on the rfc. A bit overkill, i agree. So i modified the issue to log content, as you were saying, and i modified the pr.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/vmcp/server/sessionmanager/session_manager.go
Comment thread pkg/vmcp/server/sessionmanager/session_manager.go
Comment thread pkg/vmcp/server/sessionmanager/session_manager.go Outdated
Comment thread pkg/vmcp/server/server.go Outdated
Comment thread pkg/vmcp/server/status_test.go Outdated
Comment thread pkg/vmcp/server/status_test.go
Comment thread pkg/vmcp/server/sessionmanager/session_manager.go Outdated
Replace the /status endpoint session fields with structured logging:
- CreateSession logs Info with session ID, backend count, and names
- Terminate logs Info with session ID and backend count on expiry
- StartPeriodicLogging starts a background goroutine that logs active
  session counts every minute via logActiveSessions()
- Server.Start() wires up periodic logging when SessionManagementV2 is on

Remove ListActiveSessions() from the SessionManager interface and drop
the /status session fields (Sessions, SessionsStatus, BackendUsage).

Closes: #3876

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

fix(vmcp): drop else after return in Terminate (revive lint)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yrobla yrobla requested review from ChrisJBurns and blkt as code owners March 9, 2026 11:18
@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Mar 9, 2026
Comment thread pkg/transport/session/manager.go
@yrobla yrobla marked this pull request as draft March 10, 2026 14:59
@amirejaz
Copy link
Copy Markdown
Contributor

@yrobla could you take a look at this draft PR and confirm if it’s still relevant?

@yrobla
Copy link
Copy Markdown
Contributor Author

yrobla commented Mar 31, 2026

@yrobla could you take a look at this draft PR and confirm if it’s still relevant?

well, we agreed to implement it at some point, but it was not critical. If you don't mind, i prefer to keep them as draft, to resume the work when needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[vMCP] Expose active backend sessions on health endpoint

5 participants